{template /common/header}
<div class="main">
  <div class="xiu">
    <div class="insertDiv dataDiv">
      <form name="form1" action="{U('user/mobile')}" method="post" class="secuform">
        <table>
          <tr>
            <td class="tdAlignRight" width="100" height="50">当前号码：</td>
            <td class="cityTd"><?php echo $this->userinfo['mobile_phone'];?>&nbsp;&nbsp;<a href="javascript:void(0)" class="send_code" style="color:red">免费获取验证码</a></td>
          </tr>
          <tr>
            <td class="tdAlignRight"  height="50">验证码：</td>
            <td class="cityTd"><input type="text" name="code" value="" class="input_4" datatype="*"/></td>
          </tr>
          <tr>
            <td class="tdAlignRight"  height="50">新的手机号码：</td>
            <td><input type="text" name="mobile_phone" class="input_4" ajaxurl="{U('User/Public/ajaxCheckKey')}" datatype="m" errormsg="手机号错误！" nullmsg='请填写手机号码'/></td>
          </tr>
        </table>
        <button type="submit" class="butStyle1 btnBlue" style="margin:0 auto; margin-top:15px;">提交</button>
      </form>
    </div>
  </div>
</div>
<script type="text/javascript">
				
$(function(){

    $(".send_code").click(function(){
        var text=$(this).text();
        var type=$(this).attr("type");
        if(text!="免费获取验证码"){
            return false;
        }
		var mobile=$("#mobile_phone").val();
		if(mobile==""){
			alert("请填写您的手机号码");
			$("#mobile_phone").blur();
			return;
		}
		$.ajax({url: "{U('User/Public/send_code')}&type=score&mobile=<?php echo $this->userinfo['mobile_phone'];?>",timeout: 5000,cache: false,type: "get",async : false,dataType: "json",success: function (d) {
			if(d.status==1){
				 downtime(120);	
			}
			alert(d.info);
		}});
    })

})

/**

* 验证码倒计时

* time 倒计时时间：秒

**/

function downtime(time){

//循环调用

if(time == '0'){

$('.send_code').text('免费获取验证码');

}else{

time --;

$('.send_code').text('重新发送（'+time+'）');

setTimeout(function() {

downtime(time);

},1000);} 

}
			</script> 
<script type="text/javascript">
        $(function() {
            $(".secuform").Validform({
                tiptype: 4,
                ajaxPost: true,
                callback: function(data) {
                    if (data.status == 1) {
                        alert(data.info);
                        location.href = "{U('user/mobile')}";
                    }else{
                        alert(data.info);
                    }
                }
            });
        })
    </script> 
{template /common/footer}